<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of graph_init</title>
  <meta name="keywords" content="graph_init">
  <meta name="description" content="graph_init(capacity) --- used to initialize the GRAPH_MAGIC data">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">matgraph</a> &gt; graph_init.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>graph_init
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>graph_init(capacity) --- used to initialize the GRAPH_MAGIC data</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function graph_init(capacity) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> graph_init(capacity) --- used to initialize the GRAPH_MAGIC data
 structure. 
 capacity gives the number of &quot;slots&quot; available for graphs.
 If capacity is omitted, a default capacity is used. See the
 code.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="graph_system_exists.html" class="code" title="function tf = graph_system_exists">graph_system_exists</a>	graph_system_exists checks to see if the GRAPH_MAGIC global structure has</li><li><a href="set_large.html" class="code" title="function sz = set_large(n)">set_large</a>	set_large(n) --- set the cut off size for large graphs.</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001  <span class="keyword">function</span> graph_init(capacity)
0002 <span class="comment">% graph_init(capacity) --- used to initialize the GRAPH_MAGIC data</span>
0003 <span class="comment">% structure.</span>
0004 <span class="comment">% capacity gives the number of &quot;slots&quot; available for graphs.</span>
0005 <span class="comment">% If capacity is omitted, a default capacity is used. See the</span>
0006 <span class="comment">% code.</span>
0007 
0008 DEFAULT_CAPACITY = 500;
0009 
0010 
0011 <span class="keyword">if</span> <a href="graph_system_exists.html" class="code" title="function tf = graph_system_exists">graph_system_exists</a>
0012     disp(<span class="string">'Graph system already initialized'</span>);
0013     disp(<span class="string">'To start over, use graph_destroy'</span>);
0014     <span class="keyword">return</span>;
0015 <span class="keyword">end</span>
0016 
0017 <span class="keyword">global</span> GRAPH_MAGIC;
0018 
0019 <span class="comment">% Fields in GRAPH_MAGIC:</span>
0020 <span class="comment">%   ngraphs  number of graphs we can hold in this system</span>
0021 <span class="comment">%   graphs   cell array to hold the graphs</span>
0022 <span class="comment">%   in_use   flags to show which slots are available</span>
0023 <span class="comment">%   large_size   threshold for sparse graphs</span>
0024 <span class="comment">%   Q  a deque with subfields</span>
0025 <span class="comment">%   Q.array   holds the queue values</span>
0026 <span class="comment">%   Q.first   index of first element (or 0 if none)</span>
0027 <span class="comment">%   Q.last    index of last element (or 0 if none)</span>
0028 
0029 
0030 <span class="keyword">if</span> (nargin==0)
0031     capacity = DEFAULT_CAPACITY;
0032 <span class="keyword">end</span>
0033 
0034 
0035 <span class="keyword">if</span> (capacity &lt; 1)
0036     capacity = DEFAULT_CAPACITY;
0037 <span class="keyword">end</span>
0038 
0039 GRAPH_MAGIC.ngraphs = capacity;
0040 
0041 GRAPH_MAGIC.graphs = cell(capacity,1);  <span class="comment">% hold the graphs</span>
0042 GRAPH_MAGIC.in_use = zeros(capacity,1); <span class="comment">% flag to show if slot is free</span>
0043 
0044 GRAPH_MAGIC.Q.array = [];
0045 GRAPH_MAGIC.Q.first = 0;
0046 GRAPH_MAGIC.Q.last = 0;
0047 
0048 
0049 disp([<span class="string">'Graph system initialized. Number of slots = '</span>, <span class="keyword">...</span>
0050     int2str(capacity),<span class="string">'.'</span>]);
0051 
0052 <a href="set_large.html" class="code" title="function sz = set_large(n)">set_large</a>(1000);</pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>